package com.example.orderprovider.tcc;

import com.example.orderprovider.model.Order;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * @author Kong
 * @date 2021-9-15 15:40
 */
@LocalTCC
public interface IOrderAction {
    /**
     * 一阶段 prepare
     * @param businessActionContext
     * @param order
     * @return
     */
    @TwoPhaseBusinessAction(name = "orderAction")
    boolean prepare(BusinessActionContext businessActionContext, @BusinessActionContextParameter(paramName = "order")Order order);

    /**
     * 二阶段提交
     * @param businessActionContext
     * @return
     */
    boolean commit(BusinessActionContext businessActionContext);

    /**
     * 二阶段回滚
     * @param businessActionContext
     * @return
     */
    boolean rollback(BusinessActionContext businessActionContext);
}
